from pdf2image import convert_from_path

def pdf_to_png(pdf_path, image_path):
    images = convert_from_path(pdf_path, dpi=300)
    for i, image in enumerate(images):
        print(i)
        image.save(image_path + f"/{i}.png", 'PNG')



if __name__ == "__main__":
    pdf_p='/Users/chenbingkang/Documents/安全二部/金融风控产品中心/码表数据规范需求/GBT2659/input.pdf'
    image_path='/Users/chenbingkang/Documents/安全二部/金融风控产品中心/码表数据规范需求/GBT2659/image'
    pdf_to_png(pdf_p, image_path)